<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>流程管理版本</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<div id="ligergrid1" class="sq-grid"></div>
<input hidden="true" id='manageId' name="manageId" value="${manageId }"/>
<input hidden="true" id='sysCd' name="sysCd" value="${sysCd }"/>
</div>

<script type="text/javascript">
	var grid = null;
	$(function () {
		var manageId = $("#manageId").val();
		var sysCd = $("#sysCd").val();
	    $("#ligergrid1").ligerGrid({
	    	url: '<%=path%>/system/sysflowmanagev/initList.do?manageId='+manageId+'&sysCd='+sysCd,
	    	method : 'get',
	        columns: [
		            {
		                display: '序号',
		                width: 40,
		                render: function (rowdata, rowindex, value) {
		                    var h=rowindex+1;
		                    return h;
		                }
	            	}, {
	                    display: '流程名称',
	                    name: 'procDefNm',
	                    minWidth: 100	
	                }, {
	                    display: '版本号',
	                    name: 'procDefVers',
	                    width: 60
	                }, {
	                    display: '流程状态',
	                    name: 'isValidNm',
	                    width: 80,
	                    render: function (rowdata, rowindex, value) {
	                    	if(rowdata.isValid == 1){
	                    		return LogUtils.LOG_CMM_GRID_BTN_ENABLE;
	                    	}else if(rowdata.isValid == 0){
	                    		return LogUtils.LOG_CMM_GRID_BTN_DISABLE;
	                    	}
	                    }
	                }, {
	                    display: '配置',
	                    minWidth: 280,
	                    render: function (rowdata, rowindex, value) {
	                        var h;
	                        var h1='<a class="sq-button-hasicon" href="javascript:;" onclick="disableFlow(event';
	                            h1+=",'"+rowdata.id+"'";
	                            h1+=",'ligergrid1'";
	                            h1+=")\"><i class=\"sqBtnIco_13\"></i>"+LogUtils.LOG_CMM_GRID_BTN_DISABLE+"</a>";
	                            
	                        var h2='<a class="sq-button-hasicon" href="javascript:;" onclick="enableFlow(event';
	                            h2+=",'"+rowdata.id+"'";
	                            h2+=",'ligergrid1'";
	                            h2+=")\"><i class=\"sqBtnIco_12\"></i>"+LogUtils.LOG_CMM_GRID_BTN_ENABLE+"</a>";
	                       
	                      /*  var other='&nbsp;&nbsp;&nbsp;&nbsp;<a class="sq-button-hasicon" href="javascript:;" onclick="settingDetail(event';
		                       other+=",'"+rowdata.id+"'";
		                       other+=",'ligergrid1'";
		                       other+=')"><i class="sqBtnIco_12"></i>配置详细</a>';
	                           
	                           other+='&nbsp;&nbsp;&nbsp;&nbsp;<a class="sq-button-hasicon" href="javascript:;" onclick="exportFlow(event';
	                           other+=",'"+rowdata.id+"'";
	                           other+=",'ligergrid1'";
	                           other+=')"><i class="sqBtnIco_21"></i>导出</a>'; */
	                            
	                        switch (rowdata.isValid){
	                            case 0:
	                                h=h2;
	                                break;
	                            case 1:
	                                h=h1;
	                                break;
	                            default:
	                            	h=h1;
	                            	break;
	                        }
	                        return h;
	                    }
	                } 
	            
	        ],
	        usePager: true,
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        //isScroll: false,
	        height:'100%',
	        heightDiff:-2,
	        rownumbers:false,
	        usePagerOnLessPagesize: false
	        
	        /* onRenderComplete: function () {
	        	iframeResize ();
	        } */
	    });
	    //赋值Grid
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	});
	
	//带条件重载Grid
	function reloadGrid(){
         grid.reload();
	}
	
	//配置详细
	function settingDetail(event, _id, grid){
		$.ligerDialog.SQopen({
            width: 800,
            height:400,
            title : '配置详细',
            url:'<%=path%>/customer/cstcorpteam/toAddPage.do?'
        });
	}
	
	//导出流程
	function exportFlow(event, _id, grid){
		alert(_id);
	}
	
	//禁用数据
	function disableFlow(event, _id, grid){
		var _manageId = $("#manageId").val();
		var sysCd = $("#sysCd").val();
		var parms = {
    			id:_id,
    			manageId:_manageId,
    			sysCd:sysCd
    	}
		var _url = '<%=path%>/system/sysflowmanagev/modifyDisableFlowManageV.do';
		$.ligerDialog.confirm(LogUtils.LOG_CMM_DISABLE_CONFIRM, function (flag) {
			if(flag == false)return;
			AjaxUtils.ajaxPost(_url, parms, function(msg){
				if(msg.success == 1){
					 UIUtils.alertSuccess(msg.info);
	   				 reloadGrid();
	   				 parent.reloadGrid();
	   			 }else{
	   				 UIUtils.alertError(msg.info);
	   			 }
			},true);
			
		});
	}
	
	//启用流程
	function enableFlow(event, _id, grid){
		var _manageId = $("#manageId").val();
		var sysCd = $("#sysCd").val();
		var parms = {
    			id:_id,
    			manageId:_manageId,
    			sysCd:sysCd
    	}
    	var _url = '<%=path%>/system/sysflowmanagev/modifyEnableFlowManageV.do';
    	AjaxUtils.ajaxPost(_url, parms, function(msg){
    		if(msg.success == 1){
    			 UIUtils.alertSuccess(msg.info);
				 reloadGrid();
				 parent.reloadGrid();
			 }else{
				 UIUtils.alertError(msg.info);
			 }
    	},true);
	}
	
	//清除按钮
	function clearBtn(){
		var form = new liger.get("searchBar");
		form.clear();
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
</script>
</body>
</html>